#include "openitem.h"

OpenItem::OpenItem(QString path,bool isMove)
{
    this->img.load(path);
    this->isMove=isMove;
}

QRectF OpenItem::boundingRect() const
{
    return QRectF(0,0,img.width(),img.height());
}

void OpenItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    painter->drawPixmap(0,0,img.width(),img.height(),img);
}

void OpenItem::advance(int phase)
{
    if(isMove==0)
    {
        if(collidingItems().count()>0)
        {
            return;
        }
        QString path=QString("../image/thief.png");
        img.load(path);
        this->setPos(mapToScene(-0.5,0));
    }
    else
    {
        if(collidingItems().count()>0)
        {
            return;
        }
        QString path=QString("../image/police.png");
        this->img.load(path);
        this->setPos(mapToScene(-5,0));
    //碰撞

    }
}
